﻿using System;
using System.Data;
using System.Text.RegularExpressions;
using DevExpress.XtraBars;
using UniMana.Data;
using UniMana.Utils.Data;
namespace UniMana.Win.Leadership
{
    public partial class FrmReportClass_Class_SubDepartment : DevExpress.XtraEditors.XtraForm
    {
        public FrmReportClass_Class_SubDepartment()
        {
            InitializeComponent();
            this.xucBar1.btnPrint_Click += 
                new UniMana.Utils.Controls.xucBar.ButtonClickHandler(this.btnPrint_Click);
        }
        private DBMain m_ReportClass_Department= new DBMain();
        private void ReportClass_Department_Load(object sender, EventArgs e)
        {
            DataTable result = 
                m_ReportClass_Department.m_DCReadOnly.Training_Classes.GetReport_ClassByDepartment(
                m_ReportClass_Department.m_DCReadOnly.Catalogue_Departments).ToDataTable();
            for (int i = 0; i < result.Rows.Count; i++)
            {
                
                string[] split = Regex.Split(result.Rows[i]["Name"].ToString()," ");
                if (split[0].ToUpper() == "KHOA")
                {
                    result.Rows[i]["Name"] = result.Rows[i]["Name"].ToString().Substring("KHOA".Length);
                }
            }
            grcClass_Department.DataSource = result;
            cacClassDepartment.DataSource = result;
            //grcClass_Department.DataSource = 
            //m_ReportClass_Department.m_DCReadOnly.Training_Classes.GetReport_ClassByDepartment(
            //    m_ReportClass_Department.m_DCReadOnly.Catalogue_Departments);
            ////cacClassDepartment.DataSource = 
            //m_ReportClass_Department.m_DCReadOnly.Training_Classes.GetReport_ClassByDepartment(
            //    m_ReportClass_Department.m_DCReadOnly.Catalogue_Departments);
            cacClassDepartment.Series[0].ArgumentDataMember = "Name";
            cacClassDepartment.Series[0].TopNOptions.Enabled = true;
            cacClassDepartment.Series[0].ArgumentDataMember = "Name";
            cacClassDepartment.Series[0].Name = "Khoa";
            cacClassDepartment.Series[0].TopNOptions.Enabled = true;
            cacClassDepartment.Series[0].ValueDataMembersSerializable = "Total";
        }
        private void btnPrint_Click(object sender, ItemClickEventArgs e)
        {
           // string ngaythang = 
            //"Tân An," + "ngày" + " " + DateTime.Now.Day + " " + 
            //    "tháng" + " " + DateTime.Now.Month + " " + 
            //    "năm" + " " + DateTime.Now.Year;
           //// string kyten = " Ký tên";
           // string nguoilapbang = "Người lập bảng";
            //this.compositeLinkHienThi.RtfReportFooter = 
            //this.compositeLinkHienThi.RtfReportFooter.Replace(
            //    "ngay",
            //    UniMana.Utils.Helper.String.GetRtfUnicodeEscapedString(ngaythang));
            ////this.compositeLinkHienThi.RtfReportFooter = 
            //this.compositeLinkHienThi.RtfReportFooter.Replace(
            //    "kyten", 
            //    UniMana.Utils.Helper.String.GetRtfUnicodeEscapedString(kyten));
            ////this.compositeLinkHienThi.RtfReportFooter = 
            //this.compositeLinkHienThi.RtfReportFooter.Replace(
            //    "nguoilapbang", 
            //    UniMana.Utils.Helper.String.GetRtfUnicodeEscapedString(nguoilapbang));
            //compositeLinkHienThi.ShowPreviewDialog();
        }
    }
}